package com.gaojiawei.multiThread06_ThreeSpecialVisibility;

import org.junit.Test;
import sun.java2d.loops.TransformHelper;

/**
 * 可见性测试
 */
public class l01_VisibilityDemo {

    private  boolean flag = true;

    @Test
    public void testVisibility() throws InterruptedException {

        Thread thread = new Thread(() -> {
            while (flag) {

            }
            System.out.println("thread is stopped");
        });

        thread.start();

        Thread.sleep(1000);

        flag = false;

        Thread.sleep(1000);


    }

}
